﻿'Params
'page (Optional) : The page number to fetch. Defaults to first page.
'limit (Optional) : The number of results to fetch per page. Defaults to 50.
'api_key (Required) : A Last.fm API key.
'Auth
'This service does not require authentication. 

Public Structure ChartGetHypedTracksResponse
	Public tracks() As Track
End Structure


Public Class ChartGetHypedTracks
	Inherits BaseRequest
	Dim limit As String = ""
	Dim page As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New(limit As String, page As String)
		Me.limit = limit
		Me.page = page
	End Sub

	Public Sub sendRequest()
		InitializeMembers("chart.getHypedTracks")

		AddMember("limit", limit, False)
		AddMember("page", page, False)
		AddMember("api_key", My.Settings.api_key)

		xmlresponse = sendPOSTResponse()
	End Sub

	Public Function getResponse() As ChartGetHypedTracksResponse
		Dim response As New ChartGetHypedTracksResponse
		Dim count As Integer

		Try
			count = xmlresponse.<lfm>.<tracks>.<track>.Count()
		Catch ex As Exception
			Return response
		End Try

		If (count > 0) Then
			ReDim response.tracks(count - 1)
			For i As Integer = 0 To count - 1
				response.tracks(i) = New Track(xmlresponse.<lfm>.<tracks>.<track>(i))
			Next
		End If
		Return response
	End Function
End Class
